/**
 * Copyright (c) 2011-2014, homeant (homeanter@163.com).
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package xin.homeant.upms.rpc.service.impl;

import org.springframework.beans.factory.annotation.Autowired;

import xin.homeant.upms.model.User;
import xin.homeant.upms.rpc.api.UpmsUserService;
import xin.homeant.upms.rpc.model.AppUser;
import xin.homeant.upms.service.IUserService;

/**
 * <P>
 * TODO
 * </P>
 * 
 * @author homeant homeanter@163.com
 * @Data 2017年5月21日 下午9:10:45
 */
public class UmpsUserServiceImpl implements UpmsUserService{
	
	@Autowired
	private IUserService userService;
	
	@Override
	public AppUser getUserByUsername(String username) {
		User user = userService.getUserByUsername(username);
		if(null == user) return null;
		AppUser appUser = new AppUser();
		appUser.setUsername(user.getUsername());
		appUser.setPassword(user.getPassword());
		appUser.setSalt(user.getSalt());
		appUser.setLocked(user.getAvailable() == 1 ?false:true);
		return appUser;
	}

}
